const router = require('koa-router')()

router.prefix('/users')

router.get('/', function (ctx, next) {
  ctx.body = 'this is a users response!'
})


//get
router.get('/userInfo', function (ctx, next) {

  	ctx.body = {
  		code:200,
  		data:{
  			username:"allen",
  			password:123456,
  			token:"qweqweqweweqweqwewe"
  		}
  	}
})

// post
router.post('/tableData', function (ctx, next) {

	const params = ctx.request.body;

  	ctx.response.body = {
  		code:200,
  		data:{
  			userList:[
  				{username:"张三",age:12},
  				{username:"里斯",age:12},
  				{username:"五五",age:12},
  				{username:"嘁嘁",age:12}
  			],
  			postData:params
  		}
  	}
})

module.exports = router
